import pymysql.connections

if __name__ == '__main__':
    # 获取连接对象
    conn = pymysql.connections.Connection(host="127.0.0.1",port=3306,user="root",password="root",db="test")
    # 获取游标对象
    cursor = conn.cursor()
    # 查询语句
    sql = "select * from user"
    cursor.execute(sql)
    # data = cursor.fetchall()
    # data = cursor.fetchone()
    data = cursor.fetchmany(2)
    print(data)
    conn.commit()
    cursor.close()
    conn.close()